﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace Fanbox.Photo
{
    public partial class createAbulm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            
            using (SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=Fanbox;User Id=sa;Password=123456; "))
            {
                string strInsert = string.Format("Insert Album(album_name,album_desc,created_date,update_date) values ('{0}','{1}','{2}','{2}')", this.txtName.Text.Trim(), this.txtDesc.Text.Trim(), DateTime.Now);
                SqlCommand cm = new SqlCommand(strInsert, cn);
                cn.Open();
                int result = cm.ExecuteNonQuery();
                if (result == 1)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "sk1", "alert('新建成功');parent.window.location.href = parent.window.location.href;", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "sk2", "alert('新建失败');parent.window.location.href = parent.window.location.href;", true);
                }
                cn.Close();
            }
        }
    }
}